package com.atguigu.gmall.payment.service.impl;

import com.atguigu.gmall.common.bean.ResponseVo;
import com.atguigu.gmall.common.exception.GmallException;
import com.atguigu.gmall.oms.entity.OrderEntity;
import com.atguigu.gmall.payment.feign.OmsClient;
import com.atguigu.gmall.payment.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PayServiceImpl implements PayService {
    @Autowired
    OmsClient omsClient;
    @Override
    public OrderEntity toPay(String orderToken) {

        ResponseVo<OrderEntity> orderEntityResponseVo = omsClient.queryOrderByOrderToken(orderToken);
        OrderEntity orderEntity = orderEntityResponseVo.getData();
        if(orderEntity==null){
            throw new GmallException("订单查询失败");
        }

        return orderEntity;
    }
}
